home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / amos / amoslist-0195.lzh / AMOSLIST / text0043.txt < prev    next >
Encoding:
Text File  |  1995-02-01  |  1.9 KB  |  33 lines

  1.     Sorry I can't quote what you said, but I hope you can remember what
  2. you were asking by the way I answer.
  3.     You need to be familiar with AMOS variables and understand how numbers
  4. are stored for your first two problems (BTW, I don't have an answer to your
  5. thrid).  The reason you can't get a negative result with peek is that peek
  6. must return a number between 0 and 255 (inclusinve) and AMOS doesn't deal with
  7. signed bytes (as C might).  The result is converted (I am assuming) to AMOS'
  8. default data type... I think a long integer.  So to automatically use negative
  9. numbers (without having to do the conversion yourself), you'll probably have
  10. to use loke and leek.  If you must have a signed byte, this is how 2's
  11. complement works (2's complement is how computers handle negative numbers
  12. and addition).  The range of a signed number is the same as that of an unsigned
  13. number, but everything beginning from (range+1)/2 becomes n-Range.  For instance
  14. to do a signed byte, simply accept the result of peek, then check to see if it
  15. is greater than or equal to 128.  If so, subtract 256 from it.  (Oops, up there
  16. it should read that it becomes n-Range-1, 255-0=255, 128-255-1=-128)
  17.     I won't explain precicely how the bits are flipped for subtraction and
  18. addition in 2's complement since I doubt you seed that.
  19.     With that in mind, now consider this.  Hunt searches for a string in
  20. memory.  All you have to do to search for more than a byte is convert a number
  21. into it's byte components and put them into a string.  Perhaps the easiest
  22. way to do it is to Loke or Doke the value into a reserved location and then
  23. read the bytes.  OR, probably better (I just didn't think of it first), read
  24. each byte directly from the variable location using Varptr.  If you want, for
  25. instance to search a range of memory for the value 31415926, do the following:
  26. VALUE=31415926
  27. for t=0 to 3
  28.   s$=s$+peek(varptr(VALUE)+t)
  29. next t
  30.  
  31. After you've done thism you can then hunt for s$ in you desired range of memory.
  32.  
  33.